﻿@model ArticleWeb.Models.Article
@{
    ViewBag.Title = "Edit2";
}
<link href="~/Content/css/wangEditor.min.css" rel="stylesheet" />
<style>
    .fragment {
        width: 300px;
        border: 1px solid #ccc;
        height: 120px;
        margin-top: 10px;
    }
</style>
@Html.AntiForgeryToken()
<textarea class="fragment" title="" name="item" style="display:none;"></textarea>
<div id="fragmentList">
</div>
<p>操作提示：选择一个或多个段落， 然后 CRTL + 回车键</p>
<textarea id="Content" style="height:600px;" name="Content">@Html.Raw(Model.Content)</textarea>
<br />
<p>
    <button type="button" onclick="submitData()" class="layui-btn">采编保存</button><a href="../index" class="layui-btn layui-btn-primary">返回列表</a>

</p>
<div class="layer-tpl" style="display:none;">
    <form class="layui-form" action="" lay-filter="demo1" style="padding-right:100px;padding-top:20px;">
        <div class="layui-form-item">
            <label class="layui-form-label">内容</label>
            <div class="layui-input-block">
                <textarea name="content" placeholder="请输入内容" class="layui-textarea" style="height:380px;"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">标签</label>
            <div class="layui-input-block">
                <input type="text" name="tag" required lay-verify="required" placeholder="请输入标签" autocomplete="off" class="layui-input">
            </div>
        </div>
    </form>
</div>
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    <script src="~/Content/js/wangEditor.min.js"></script>
    <script>
        var editor = new wangEditor('Content');
        editor.config.menuFixed = false;
        editor.config.menus = [
            'fullscreen',
            //'|',
           'source',
           //'|',
           //'bold',
           //'underline',
           //'italic',
           //'strikethrough',
           //'eraser',
           //'forecolor',
           //'bgcolor',
        ];
        editor.create();
        app.use('article/edit2');



        var submitData = function () {
            var items = $('.fragment:visible');
            if (items.length == 0) {
                layer.msg("请先采编一些段落");
            }
            else {
                layer.msg("正在处理...");
                var data = { __RequestVerificationToken: $('[name=__RequestVerificationToken]').val() };
                data.id = '@Model.ID';
                data.json = JSON.stringify(fragemets);
                $.post("./", data, function (d) {
                    layer.msg(d.msg);
                });
            }
        }
    </script>
}
